<?php
/**
 * [DB模型]
 * 
 * @version $Id: Terms.php 645 2013-01-23 03:49:03Z linsir123 $
 */
class dbTerms extends ActiveRecord 
{
	/**
	 * @var 数据库表名
	 */
	public $table = 'terms';
	
	/**
	 * @var [分表]对应的创建分表的SQL
	 */
	public $sqlPartition = "
CREATE TABLE IF NOT EXISTS `%s` (
  `id` int(11) NOT NULL auto_increment COMMENT 'ID',
  `pinyin` varchar(255) NOT NULL COMMENT '拼音',
  `term` varchar(255) NOT NULL COMMENT '内容',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `pinyin` (`pinyin`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='关键字拼音表' AUTO_INCREMENT=1 ;
	";
	
	/**
	 * 保存
	 */
	public function save($pinyin, $term)
	{
		return $this->insertDuplicate(array(
			'pinyin' => $pinyin,
			'term' => $term,
		), array(), array('term'));
	}
	
	/**
	 * 取
	 */
	public function get($pinyin)
	{
		return $this->getBy('pinyin', $pinyin, 'term');
	}
}
